﻿namespace UsefulTools.ExtensionMethods
{
    using System.Collections.Generic;
    using System.Linq;
    using System.Xml.Linq;

    public static class Xml
    {


        public static IEnumerable<XElement> ElementsAnyNs<T>(this T source, string localName)
    where T : XElement
        {
            return source.Elements().Where(e => e.Name.LocalName == localName);
        }
        public static XElement ElementAnyNs<T>(this T source, string localName)
    where T : XElement
        {
            return source.Elements().Single(e => e.Name.LocalName == localName);
        }
        public static IEnumerable<XElement> DescendantsAnyNs<T>(this T source, string localName)
    where T : XElement
        {
            return source.Descendants().Where(e => e.Name.LocalName == localName);
        }
    }
}